package cn.edu.seu.ssny.entity;

import com.alibaba.fastjson.annotation.JSONField;
import cn.edu.seu.ssny.entity.support.BaseEntity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter

/**
 * 项目表
 */
@Entity
@Table(name = "tb_project")
public class Project extends BaseEntity implements Comparable<Object> {


    /**
     * 项目id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Integer id;
    /**
     * 项目名称
     */
    private String name;

    /**
     * 唯一标签
     */
    @Column(unique = true)
    private String identification;

    /**
     * 城市
     */
    private String city;

    /**
     * 项目描述,详细信息
     */
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "text")
    private String description;

    /**
     * 项目起始时间
     */
    @JSONField(format = "yyyy-MM-dd")
    @Column(columnDefinition = "DATE")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    /**
     * x坐标
     */
    private Double coordinateX;

    /**
     * y坐标
     */
    private Double coordinateY;
    /**
     * 图片url
     */
    private String image;
    /**
     * panel图片url
     */
    private String panel;

    /**
     * 保养流程图
     */
    private String maintainImgSrc;

    /**
     * panel图片x坐标
     */
    private Double panelX;
    /**
     * panel图片y坐标
     */
    private Double panelY;
    /**
     * 字体
     */
    private String font;
    /**
     * 字体大小
     */
    private String fontSize;

    /**
     * 最大冷负荷
     */
    private Double maxColdLoad;

    /**
     * 最大热负荷
     */
    private Double maxHotLoad;

    /**
     * 项目占地面积
     */
    private Double area;

    @Override
    public int compareTo(Object arg0) {
        Project prj = (Project) arg0;
        return id.compareTo(prj.getId());//根据id排序
    }

    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Enterprise.class)
    @JoinColumn(name = "enterprise_id", referencedColumnName = "id")
    @JSONField(serialize = false)
    private Enterprise enterprise;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Device.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<Device> devices;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Equipment.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<Equipment> equipments;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Alarm.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<Alarm> alarms;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = DeviceCategory.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<DeviceCategory> deviceCategories;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = DeviceCategoryCommon.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<DeviceCategoryCommon> deviceCommonCategories;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = EquipmentTypeInProject.class, mappedBy = "project")
    @JSONField(serialize = false)
    private List<EquipmentTypeInProject> equipmentTypeList;
}
